package org.jeecg.modules.flowable.listener;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener;
import org.jeecg.modules.flowable.handle.InstanceCompletedHandle;
import org.springframework.stereotype.Component;

/**
 * 流程完成监听回调
 *
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class ProcessCompletedListener extends AbstractFlowableEngineEventListener {


    final InstanceCompletedHandle instanceCompletedHandle;


    @Override
    protected void processCompleted(FlowableEngineEntityEvent event) {
        log.info("process completed ");
        // 整体流程完成触发
        String instId = event.getProcessInstanceId();

        log.info("流程 instId：{} 结束！", instId);
        // 执行流程结束拓展流程
        this.instanceCompletedHandle.completed(instId);
    }
}